#include "GACSegmentation.h"
#include <FL/fl_ask.H>

GACSegmentation::GACSegmentation(void)
{
	m_GeodesicActiveContourFilter = GeodesicActiveContourFilterType::New();
  m_GeodesicActiveContourFilter->SetInput(  m_FastMarchingFilter->GetOutput() );
  m_GeodesicActiveContourFilter->SetFeatureImage(   m_SigmoidFilter->GetOutput() );

  m_GeodesicActiveContourFilter->SetCurvatureScaling( 0.1 );
  m_GeodesicActiveContourFilter->SetPropagationScaling( 1.0 );
  m_GeodesicActiveContourFilter->SetAdvectionScaling( 1.0 );
  m_GeodesicActiveContourFilter->UseImageSpacingOn();


   m_ThresholdFilter->SetInput( m_GeodesicActiveContourFilter->GetOutput() );
  m_ThresholdFilter->SetUpperThreshold( itk::NumericTraits<InternalPixelType>::Zero ); 
  m_ThresholdFilter->SetLowerThreshold( itk::NumericTraits<InternalPixelType>::NonpositiveMin() ); 
  m_ThresholdFilter->SetInsideValue(   1 );
  m_ThresholdFilter->SetOutsideValue(  0 );
}



GACSegmentation::~GACSegmentation(void)
{
}


void
GACSegmentation
::RunGeodesicActiveContour( void )
{

  // update the marching filter
  try
    {
    this->ComputeEdgePotential();
    this->ComputeFastMarching();
    this->ShowStatus("Computing Geodesic Active Contour Filter");
    m_GeodesicActiveContourFilter->Update();
    }
  catch( itk::ExceptionObject & exp )
    {
    fl_alert( exp.GetDescription() );
    }

}